package com.ruoyi.business.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.bizsys.domain.SmsTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bizsys.domain.BatchJobMonitoring;
import com.ruoyi.bizsys.domain.DateBatchFailLoan;
import com.ruoyi.business.mapper.BatchDateJobMapper;
import com.ruoyi.business.service.IBatchDateJobService;
import com.ruoyi.common.utils.DateUtils;

@Service
public class BatchDateJobServiceImpl implements IBatchDateJobService {
	
	@Autowired
	BatchDateJobMapper batchDateJob;

	@Override
	public BatchJobMonitoring getBatchDateRecord() {
		return batchDateJob.getBatchDateRecord();
	}

	@Override
	public boolean isTodayBatchJobSuccess() {
		BatchJobMonitoring result = this.getBatchDateRecord();
		
		if(null != result) {
			String today = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date());
			String batchDate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, result.getBatchDate());
			return today.equals(batchDate);
		}
		
		return false;
	}

	@Override
	public List<DateBatchFailLoan> getBatchJobFailRecord(String batchDate) {
		return batchDateJob.getBatchJobFailRecord(batchDate);
	}

	@Override
	public int saveBatchSmsTask(List<SmsTask> smsTasks) {
		return batchDateJob.saveBatchSmsTask(smsTasks);
	}

}
